package netTracker.network;

import netTracker.NetTracker;
import netTracker.Util;

/**
 * A message handler for messages specifically sent to a session server.
 * @author David Cummings
 */
public class GlobalMessageHandler implements MsgHandler {
	/** Utility class with debug flag: */
	Util util = new Util(this, true);
	
	Message m;
	NetTracker netTracker;
	
	public GlobalMessageHandler(NetTracker netTracker){
		this.netTracker = netTracker;
	}
	
	public void handleMsg(Message m) throws PostalException {
		this.m = m;
		
		if(m.getTag().equals("NOTE")){
			try{
				String[] location = m.getMsg().split(",");
				netTracker.addNote(m.getNote(), Integer.parseInt(location[0]), 
						Integer.parseInt(location[1]));
			}catch(Exception x){
				util.debug("Error processing NOTE message: "+x);
			}
		}
	}
}
